# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
x = [5, 10, 15, 20, 25, 30]

import matplotlib as mpl
mpl.rcParams['font.family'] = 'Times New Roman'
#mpl.rcParams['font.sans-serif'] = 'NSimSun,Times New Roman'
"""

"""
#y1 = [0.30081300813008127, 0.35610766045548664, 0.29855072463768106, 0.36178861788617883, 0.3934426229508196, 0.39285714285714285]
#y2 = [0.42494426819360137, 0.5118881618512089, 0.49596052118493844, 0.5419979457416314, 0.5200807808592434, 0.5375622992982383]
#y3 = [0.5248142594359076, 0.591260475866431, 0.5739816994523705, 0.6190628672159285, 0.5994917237214729, 0.6212189891724988]


def string2float_array(s):
    return list(map(float, s.split()))


plt.subplot(3, 1, 1)
plt.ylim(0.1, 0.5)

y1 = string2float_array("0.30081300813008127	0.35610766045548664	0.29855072463768106	0.36178861788617883	0.3934426229508196	0.39285714285714285")
y2 = string2float_array("0.26829268292682923	0.38509316770186347	0.34492753623188405	0.31300813008130085	0.2622950819672131	0.3454421768707483")
y3 = string2float_array("0.14634146341463414	0.3043478260869566	0.2666666666666666	0.3333333333333333	0.3169398907103825	0.3197278911564626")
plt.plot(x, y1, 's-', label='Multi-Channel')
plt.plot(x, y2, '^-', label='Bi-LSTM')
plt.plot(x, y3, '*-', label='CNN')
plt.ylabel('nDCG@1')

plt.subplot(3, 1, 2)
plt.ylim(0.1, 0.6)

y1 = string2float_array("0.42494426819360137	0.5118881618512089	0.49596052118493844	0.5419979457416314	0.5200807808592434	0.5375622992982383")
y2 = string2float_array("0.3973425662903955	0.4956525268372291	0.49540720135587996	0.49673684327578144	0.428309939304487	0.502489813696253")
y3 = string2float_array("0.29109003914455456	0.47269359763956637	0.4566451311523632	0.4822132461034545	0.4730362387615096	0.4798617935131974")

plt.plot(x, y1, 's-', label='Multi-Channel')
plt.plot(x, y2, '^-', label='Bi-LSTM')
plt.plot(x, y3, '*-', label='CNN')
plt.ylabel('nERR@10')

plt.ylim(0.2, 0.6)
plt.subplot(3, 1, 3)

y1 = string2float_array("0.5248142594359076	0.591260475866431	0.5739816994523705	0.6190628672159285	0.5994917237214729	0.6212189891724988")
y2 = string2float_array("0.4931522798671403	0.5917457158634767	0.5840876210219378	0.5798627421899663	0.5046505473426794	0.5778597579819402")
y3 = string2float_array("0.37549260517902217	0.5483166830479659	0.5432723994219739	0.5719223616847311	0.5539169508590923	0.5589457001639984")

plt.plot(x, y1, 's-', label='Multi-Channel')
plt.plot(x, y2, '^-', label='Bi-LSTM')
plt.plot(x, y3, '*-', label='CNN')
plt.xlabel('Post Length in STC')
plt.ylabel('P+')
plt.legend(loc='best')

#plt.savefig("length.png")
plt.show()


# fig, (ax0, ax1, ax2) = plt.subplots(nrows=3)
#
# ax0.plot(x, y1, label='nDCG@1', )
# ax0.plot(x, y2, label='nERR@10')
# ax0.plot(x, y3, label='P+')
#
# ax1.plot(x, y1, label='nDCG@1', )
# ax1.plot(x, y2, label='nERR@10')
# ax1.plot(x, y3, label='P+')
#
# ax2.plot(x, y1, label='nDCG@1', )
# ax2.plot(x, y2, label='nERR@10')
# ax2.plot(x, y3, label='P+')
#
# plt.show()

# plt.figure(1)
# plt.subplot(211)
#
# plt.ylim(0.2, 0.8)

#
# plt.subplot(212)
# plt.xlabel('Length Max')
#
#
# plt.plot(x, y1, label='nDCG@1', )
# plt.plot(x, y2, label='nERR@10')
# plt.plot(x, y3, label='P+')
#
# # plt.title('line chart')
# plt.xlabel('Length')
# plt.legend()
#
# plt.ylim(0.1, 0.9)
#
# plt.show()
#plt.savefig('vis.png')

# import numpy as np
# import matplotlib.pyplot as plt
#
# fig, axs = plt.subplots(1, 2)
#
# x = np.arange(0.0, 2.0, 0.02)
# y1 = np.sin(2 * np.pi * x)
# y2 = np.exp(-x)
# l1, l2 = axs[0].plot(x, y1, 'rs', x, y2, 'go')
#
# y3 = np.sin(4 * np.pi * x)
# y4 = np.exp(-2 * x)
# l3, l4 = axs[1].plot(x, y3, 'yd', x, y4, 'k^')
#
# fig.legend((l1, l2), ('Line 1', 'Line 2'), 'upper left')
# fig.legend((l3, l4), ('Line 3', 'Line 4'), 'upper right')
#
# plt.tight_layout()
# plt.show()


